package com.cm.caseManagement.controller;


import com.cm.caseManagement.annotation.Log;
import com.cm.caseManagement.core.controller.BaseController;
import com.cm.caseManagement.core.domain.AjaxResult;
import com.cm.caseManagement.core.page.TableDataInfo;
import com.cm.caseManagement.pojo.entity.CmConvictedNotExecuted;
import com.cm.caseManagement.pojo.enums.BusinessType;
import com.cm.caseManagement.service.ICmConvictedNotExecutedService;
import com.cm.caseManagement.utils.poi.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 已判未执行Controller
 *
 * @author ruoyi
 * @date 2025-10-05
 */
@RestController
@RequestMapping("/caseManagement/executed")
public class CmConvictedNotExecutedController extends BaseController
{
    @Autowired
    private ICmConvictedNotExecutedService cmConvictedNotExecutedService;

    /**
     * 查询已判未执行列表
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:executed:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmConvictedNotExecuted cmConvictedNotExecuted)
    {
        startPage();
        List<CmConvictedNotExecuted> list = cmConvictedNotExecutedService.selectCmConvictedNotExecutedList(cmConvictedNotExecuted);
        return getDataTable(list);
    }

    /**
     * 导出已判未执行列表
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:executed:export')")
    @Log(title = "已判未执行", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmConvictedNotExecuted cmConvictedNotExecuted)
    {
        List<CmConvictedNotExecuted> list = cmConvictedNotExecutedService.selectCmConvictedNotExecutedList(cmConvictedNotExecuted);
        ExcelUtil<CmConvictedNotExecuted> util = new ExcelUtil<CmConvictedNotExecuted>(CmConvictedNotExecuted.class);
        util.exportExcel(response, list, "已判未执行数据");
    }

    /**
     * 获取已判未执行详细信息
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:executed:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cmConvictedNotExecutedService.selectCmConvictedNotExecutedById(id));
    }

    /**
     * 新增已判未执行
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:executed:add')")
    @Log(title = "已判未执行", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmConvictedNotExecuted cmConvictedNotExecuted)
    {
        return toAjax(cmConvictedNotExecutedService.insertCmConvictedNotExecuted(cmConvictedNotExecuted));
    }

    /**
     * 修改已判未执行
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:executed:edit')")
    @Log(title = "已判未执行", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmConvictedNotExecuted cmConvictedNotExecuted)
    {
        return toAjax(cmConvictedNotExecutedService.updateCmConvictedNotExecuted(cmConvictedNotExecuted));
    }

    /**
     * 删除已判未执行
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:executed:remove')")
    @Log(title = "已判未执行", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cmConvictedNotExecutedService.deleteCmConvictedNotExecutedByIds(ids));
    }
}
